#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;

template<class T, typename S> 
void swap(T& a, S& b) {
    T temp;
    temp = a;
    a = b;
    b = temp;
}

template<typename T>
const T& mymax(const T& a,const T& b){
    return a>b ? a:b;
}

int main() {
    int a = 10, b = 20;
    printf("a is %d, b is %d\n", a, b);
    swap(a, b);
    printf("a is %d, b is %d\n", a, b);

    cout<<mymax(2.1,2.2)<<endl;//模板实参被隐式推演成double
    cout<<mymax<double>(2.1,2.2)<<endl;//显示指定模板参数。
    cout<<mymax<int>(2.1,2.2)<<endl;//显示指定的模板参数，会将函数函数直接转换为int。
    return 1;
}
